﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Reflection;

namespace Keeyo.DataHelper
{
    public interface IQuery<T> where T : Entity, new()
    {
        string ConnectionString { get; set; }
        string Exclude { get; set; }
        string Include { get; set; }

        T SelectByID(object ID);
        T Select(string WhereString);
        T Select(string WhereString, IDataParameter[] DataParameter);
        T Select(string WhereString, string OrderString, IDataParameter[] DataParameter);

        IList<T> SelectAll();
        IList<T> SelectAll(string WhereString, string OrderString);
        IList<T> SelectAll(string WhereString, string OrderString, IDataParameter[] DataParameter);
        IList<T> SelectAll(int TopN, string WhereString, string OrderString, IDataParameter[] DataParameter);
        IPagingList<T> SelectAll(string WhereString, string OrderString, int Page, int PageSize);
        IPagingList<T> SelectAll(string WhereString, string OrderString, IDataParameter[] DataParameter, int Page, int PageSize);

        int GetCount();
        int GetCount(string WhereString);
        int GetCount(string WhereString, IDataParameter[] DataParameter);

        int Insert(T Entity);

        int Update(T Entity);
        int Update(T Entity, string WhereString, IDataParameter[] DataParameter);

        int Delete(object ID);
        int Delete<K>(K[] IDs);
        int Delete(string WhereString, IDataParameter[] DataParameter);

        string GetSelectString();
        string GetSelectString(int TopN);
        string GetInsertString();
        string GetUpdateString();
    }

    public interface IQuery
    {
        string ConnectionString { get; set; }

        IDbConnection GetDbConnection();

        IDataReader ExecuteReader(IDbTransaction Transaction, string SQLText, IDataParameter[] DataParameter, CommandType CommandType);
        IDataReader ExecuteReader(string SQLText, IDataParameter[] DataParameter, CommandType CommandType);
        IDataReader ExecuteReader(string SQLText, IDataParameter[] DataParameter);
        IDataReader ExecuteReader(string SQLText);

        int ExecuteNonQuery(IDbTransaction Transaction, string SQLText, IDataParameter[] DataParameter, CommandType CommandType);
        int ExecuteNonQuery(string SQLText, IDataParameter[] DataParameter, CommandType CommandType);
        int ExecuteNonQuery(string SQLText, IDataParameter[] DataParameter);
        int ExecuteNonQuery(string SQLText);

        object ExecuteScalar(IDbTransaction Transaction, string SQLText, IDataParameter[] DataParameter, CommandType CommandType);
        object ExecuteScalar(string SQLText, IDataParameter[] DataParameter, CommandType CommandType);
        object ExecuteScalar(string SQLText, IDataParameter[] DataParameter);
        object ExecuteScalar(string SQLText);
    }
}
